package com.haofengsoft.scce.db.biz.consultation;

import java.util.List;

import android.content.Context;

import com.haofengsoft.scce.ManageApplication;
import com.haofengsoft.scce.db.DaoSession;
import com.haofengsoft.scce.db.dao.consultation.FocusNewDao;
import com.haofengsoft.scce.db.entity.consultation.FocusNew;

import de.greenrobot.dao.query.QueryBuilder;

/**
 * Created by admin on 2015/7/23.
 */
public class FocusNewBiz {
    private static FocusNewBiz instance;
    private static Context appContext;
    private FocusNewDao dao;

    private FocusNewBiz() {
    }

    public static FocusNewBiz getInstance(Context context) {
        if (instance == null) {
            instance = new FocusNewBiz();
            if (appContext == null) {
                appContext = context.getApplicationContext();
            }
            DaoSession daoSession = ManageApplication.getDaoSession(context);
            instance.dao = daoSession.getFocusNewDao();
        }
        return instance;
    }


    public void insertFocusNewList(final List<FocusNew> infoList) {
        dao.insertOrReplaceInTx(infoList);
    }

    public List<FocusNew> gainFocusNewList() {
        QueryBuilder qb = dao.queryBuilder();
        qb.orderDesc(FocusNewDao.Properties.StrCreateDate);
        return qb.list();
    }

    //删除
    public void deleteAll() {
        dao.deleteAll();
    }
}
